/*
 * Regola grammaticale:
 * <factb> → OPAR <cond> CPAR
 * 
 * Simboli terminali:
 * OPAR → "("
 + CPAR → ")"
 */
package composite.boolean_expression.factb;

import composite.Component;
import composite.boolean_expression.Cond;
import composite.boolean_expression.Factb;
import visitor.Visitor;

/**
 *
 * @author Antonio
 */
public class FactbCond extends Factb {

    private Cond cond;

    public FactbCond(Cond cond) {

        if (cond == null) {

            throw new NullPointerException();
        }

        this.cond = cond;
    }

    public Cond getState() {

        return cond;
    }// getState

    @Override
    public void interpreta(String contesto) {

        cond.interpreta(contesto);
    }

    @Override
    public void accept(Visitor v) {

        v.visit(this);
    }

    @Override
    public String toString() {

        StringBuilder sb = new StringBuilder();

        sb.append(" (").append(cond).append(") ");

        return sb.toString();
    }

    @Override
    public void add(Component c) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
